package cn.com.connected.common.emnus;


import cn.com.connected.base.exception.BusinessException;
import cn.com.connected.base.exception.ErrorCode;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public enum ScopeType {
	school_wx("school_wx","wx会员"),

	;

	private String value;
	private String name;


	ScopeType(String value, String name){
		this.value = value;
		this.name = name;
	}
	public String getValue(){
		return value;
	}
	public String getName(){
		return name;
	}

	public static ScopeType getByValue(String value){
		for (ScopeType fileType : ScopeType.values()) {
			if (fileType.getValue().equals(value)){
				return fileType;
			}
		}
		throw new BusinessException(ErrorCode.SERIOUS_REQUEST);
	}

	public static List<Map> toMap(){
		return Arrays.stream(ScopeType.values()).map(o->new HashMap(){{put("name",o.getName());put("value",o.getValue());}}).collect(Collectors.toList());
	}
}
